import config from "./config.js"

const getStorage = () => {
    return wx.getStorageSync(config.namespace) || {};
}

const get = (key) => {
    return getStorage()[key]
}

const set = (key , value) => {
    let storage = getStorage();
    storage[key] = value
    wx.setStorageSync(config.namespace, storage)
}


const remove = (key) => {
    let storage = getStorage();
    delete storage[key]
    wx.setStorageSync(config.namespace, storage)
}


const clear = () => {
    wx.clearStorageSync();
}


export default {
    get,
    set,
    remove,
    clear,
}